package com.mbti.youmore.controller;

import com.mbti.youmore.entity.Business;
import com.mbti.youmore.entity.User;
import com.mbti.youmore.entity.resp.ResponseData;
import com.mbti.youmore.service.BusinessService;
import com.mbti.youmore.service.StatisticsService;
import com.mbti.youmore.service.UserService;
import com.mbti.youmore.util.AccessTokenUtils;
import com.mbti.youmore.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.sql.Timestamp;
import java.util.Date;

@RequestMapping(path = "/integarl")
@RestController
public class IntegralController {

    @Autowired
    private StatisticsService statisticsService;
    @Autowired
    private UserService userService;
    //签到加积分
    @PostMapping("/signin")
    public ResponseEntity<?> signIn(@RequestParam("userId") Integer userId) {
        Date lastTime = new Timestamp(new Date().getTime());
        return userService.signIn(userId,lastTime);
    }

    //浏览加积分
    @PostMapping("/browsein")
    public ResponseEntity<?> browseIn() {
        Integer userId = AccessTokenUtils.getUserId();
        Date lastTime = new Timestamp(new Date().getTime());
        return userService.browseIn(userId,lastTime);
    }
    //发帖加积分
//    @PostMapping("/postin")
//    public ResponseEntity<?> postIn() {
//        Integer userId = AccessTokenUtils.getUserId();
//        Date lastTime = new Timestamp(new Date().getTime());
//        return userService.postIn(userId,lastTime);
//    }

}
